import { createBrowserRouter } from "react-router-dom";

const routers = createBrowserRouter([
  {
    path: "/",
    lazy: async () => {
      const { default: App } = await import("../App");
      return {
        element: <App />,
      };
    },
    children: [
      {
        path: "home",
        lazy: async () => {
          const { default: Home, loader } = await import(
            "../pasre/tabs/Home/Index"
          );
          return {
            element: <Home />,
            loader,
          };
        },
      },
      {
        path: "shiping",
        lazy: async () => {
          const { default: Shiping } = await import(
            "../pasre/tabs/Shiping/Index"
          );
          return {
            element: <Shiping />,
          };
        },
      },
      {
        path: "chat",
        lazy: async () => {
          const { default: Chat } = await import("../pasre/tabs/Chat/Index");
          return {
            element: <Chat />,
          };
        },
      },
      {
        path: "list",
        lazy: async () => {
          const { default: List } = await import("../pasre/tabs/List/Index");
          return {
            element: <List />,
          };
        },
      },
      {
        path: "my",
        lazy: async () => {
          const { default: My } = await import("../pasre/tabs/My/Index");
          return {
            element: <My />,
          };
        },
      },
    ],
  },
  {
    path: "/zhuce",
    lazy: async () => {
      const { default: Zhuce } = await import("../pasre/zhuce/Index");
      return {
        element: <Zhuce />,
      };
    },
  },
  {
    path: "/mengpiao",
    lazy: async () => {
      const { default: Mengpiao ,loader} = await import("../pasre/menpiao/Index");
      return {
        element: <Mengpiao />,
        loader
      };
    },
  },
  {
    path: "/city",
    lazy: async () => {
      const { default: City, loader } = await import("../pasre/city/Index");
      return {
        element: <City />,
        loader,
      };
    },
  },
  {
    path: "/xqy/:id",
    lazy: async () => {
      const { default: Xqy, loader } = await import("../pasre/xqy/Index");
      return {
        element: <Xqy />,
        loader,
      };
    },
  },
  {
    path: "/login",
    lazy: async () => {
      const { default: Denglu } = await import("../pasre/login/index");
      return {
        element: <Denglu />,
      };
    },
  },
  {
    path: "*",
    lazy: async () => {
      const { default: Cuo } = await import("../pasre/404/Index");
      return {
        element: <Cuo />,
      };
    },
  },
]);

export default routers;
